var request = require('request');
var cheerio = require('cheerio');
var fs = require('fs');



function getjson(url){
	request(url,function(error, response, body) {
		var text = '';
		var $ = cheerio.load(body);
		text += $('.bookname').find('h1').text()
		console.log($('.bookname').find('h1').text())
		text += $('#content').text()
		
		fs.appendFile('./bhxnm.txt', text, (err) => {
		  	if (err) throw err;
		});
		getjson('https://www.dingdiann.com'+$('.next').attr('href'))
		
	})
}

function aaa(xx){
	aaa(getjson('https://www.dingdiann.com'+xx))
}

getjson('https://www.dingdiann.com/ddk95596/5037164.html')